Skip to main content

All Questions

2votes
1answer
330views

In poltergeist, whats wrong with "solely to trigger or initialize several other objects"? Isn't it is a good use of encapsulation and reuse?

After reading What differentiates function objects from poltergeists?, according to the definition of poltergeist, I still don't understand why would "poltergeist" be a bad pattern: A ...
wcminipgasker2023's user avatar
1vote
2answers
651views

No trivial god-class refactoring

Consider you have the following code: class UserContainer { List<User> user; //some methods to get specific users, for example users, which are higher than 1,70meters } The User have a ...
Robin Kreuzer's user avatar
2votes
3answers
472views

Swappable state object or decoupling data and functions

I come from OOP pradigm and I also know a bit about functional programming and its advantages. Over time I came to like the separation of data and transformations that are applied to it using pure ...
konrad's user avatar
0votes
1answer
180views

How to bring a code to conformance with tell, don't ask without creating tons of methods on other classes?

It used to be fairly common for people to call a getter, do some calculation on it, then call a setter with the result. This is a clear sign your calculation actually belongs to the class you called ...
gaazkam's user avatar
  • 4,519
3votes
1answer
138views

Auto-Initializable Objects Pattern

I'm working on a system where we consistently apply "patterns" or approaches such as Dependency Injection. I'd rather not expose the current underlying technology as not to get biased solutions, ...
Bruno Brant's user avatar
2votes
3answers
2kviews

How to manage configuration and state in a program

At my company we have multiple C# programs that use Dictionaries in a config class to keep track of the configuration and state of the program. For example, bool isFoo = config.GetBool("Foo"); This ...
Era's user avatar
  • 128
0votes
0answers
414views

A modification of singleton pattern

"Singleton" is widely considered anti-pattern ("bad" in everyday language). What about this alternative modified singleton pattern? An object constructor for our class ensures that at any given ...
porton's user avatar
1vote
1answer
402views

Is there an official name for the "one object disease" anti-pattern (iterative single object operations on databases, services etc.)?

It is caused by the naive programming paradigm: focus on just a single object, do something with it, and if you have to work with many objects, you loop, iterate and traverse, repeating the operation ...
Erik Hart's user avatar
5votes
2answers
4kviews

What alternatives to a singleton are there for a class which only can have one instance?

I need to represent an abstraction over various parts of the hardware for a game. I'm trying to decouple the code that does things like manage the logic of the game from the code that is API/platform ...
user112513312's user avatar
37votes
11answers
7kviews

Constructor-only subclasses: Is this an anti-pattern?

I was having a discussion with a co-worker, and we ended up having conflicting intuitions about the purpose of subclassing. My intuition is that if a primary function of a subclass is to express a ...
HardlyKnowEm's user avatar
47votes
11answers
11kviews

Are error variables an anti-pattern or good design?

In order to handle several possible errors that shouldn't halt execution, I have an error variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to ...
Mikayla Maki's user avatar
65votes
8answers
29kviews

Is ORM an Anti-Pattern? [closed]

I had a very stimulating and interessting discussion with a colleague about ORM and its pros and cons. In my opinion, an ORM is useful only in the rarest cases. At least in my experience. But I don't ...
derphil's user avatar

close